package cn.lei.uicontrols;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;

public class AtyUsingAutoCompleteTextView extends AppCompatActivity {

    private AutoCompleteTextView mAutoCompleteTextView;
    private MultiAutoCompleteTextView mMultiAutoCompleteTextView;
    private ArrayAdapter<String> mArrayAdapter, mactvAdapter;
    private String[] strs = new String[]{"Hello", "Hello world", "Hello android", "java", "javascript"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aty_using_auto_complete_text_view);

        mArrayAdapter = new ArrayAdapter<String>(this, R.layout.aty_using_autocompletetextview_dropdown_item, strs);

        mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
        mAutoCompleteTextView.setAdapter(mArrayAdapter);

        mMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView);
        mactvAdapter = new ArrayAdapter<String>(this, R.layout.aty_using_autocompletetextview_dropdown_item, strs);
        mMultiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
        mMultiAutoCompleteTextView.setAdapter(mactvAdapter);
        
    }
}
